<html>
<head>
<#import "/common/common.ftl" as netCommon>
<@netCommon.commonStyle />
<title></title>
<@netCommon.commonScript /> 
<@netCommon.commonLayui /> 
</head>
<body class="layui-layout-body show-scroll-y">
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-sm12">
				<div class="layui-card">
					<div class="layui-card-header">
						位置信息
					</div>
					<div class="layui-card-body">
						<div class="layui-row layui-col-space5">
							<div class="layui-col-md3">
						      	<img alt="" id="wzzp" src="${request.contextPath}/static/images/empty_card.jpg" class="image-view-show"/>
						    </div>
						    <div class="layui-col-md9">
						      	<table class="layui-table">
						      		<tbody>
						      			<tr>
						      				<th>位置名称</th>
						      				<td id="wzmc"></td>
						      				<th>位置编号</th>
						      				<td id="wzbh"></td>
						      			</tr>
						      			<tr>
						      				<th>位置描述</th>
						      				<td colspan="3">
						      					<textarea placeholder="请输入内容" name="wzms" id="wzms" lay-verify="wzms" class="layui-textarea"></textarea>
						      				</td>
						      			</tr>
						      		</tbody>
						      	</table>
						    </div>
					    </div>
					</div>
				</div>
			</div>
			<div class="layui-col-sm12">
				<div class="layui-card">
					<div class="layui-card-header">
						柜（架）信息
					</div>
					<div class="layui-card-body">
						<div class="layui-row layui-col-space5">
							<div class="layui-col-md3">
							    <img alt="" id="zwgzp" src="${request.contextPath}/static/images/empty_card.jpg" class="image-view-show"/>
							</div>
							<div class="layui-col-md9">
								<form class="layui-form" lay-filter="editFrom" id="editFrom" action="">
									<input type="hidden" name="objectid" id="objectid" value="${objectid!}" />
									<input type="hidden" name="wzxxOid" id="wzxxOid" value="${wzxxOid!}" />
									<input type="hidden" name="glwzbh" id="glwzbh" value="" />
									<div class="layui-form-item">
										<div class="layui-inline">
											<label class="layui-form-label">置物柜说明</label>
											<div class="layui-input-block">
												<input type="text" name="zwgmc" lay-verify="required"
													placeholder="请输入"  class="layui-input" value="" />
											</div>
										</div>
										<div class="layui-inline">
											<label class="layui-form-label">置物柜编号</label>
											<div class="layui-input-block">
												<input type="text" name="zwgbh" lay-verify="required"
													placeholder="请输入"  class="layui-input" value="" />
											</div>
										</div>
									</div>
									<div class="layui-form-item">
										<div class="layui-inline">
											<label class="layui-form-label">层数</label>
											<div class="layui-input-block">
												<input type="text" name="zwgcs" lay-verify="number"
													placeholder="请输入"  class="layui-input" value="" />
											</div>
										</div>
										<div class="layui-inline">
											<label class="layui-form-label">每层格数</label>
											<div class="layui-input-block">
												<input type="text" name="zwgcgs" lay-verify="number"
													placeholder="请输入"  class="layui-input" value="" />
											</div>
										</div>
									</div>
									<div class="layui-form-item">
										<label class="layui-form-label">照片</label>
										<div class="layui-input-block">
											<button type="button" id="upImg" class="layui-btn"  lay-filter=""><i class="layui-icon">&#xe64a;</i> 上传照片</button>
										</div>
									</div>
									<div class="layui-form-item line-center">
										<button type="submit" class="layui-btn" lay-submit lay-filter="saveBtn">保存</button>
										<button type="button" class="layui-btn layui-btn-primary" id="testBtn">效果预览</button>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-col-sm12">
				<div class="layui-card">
					<div class="layui-card-header">
						示意图预览
					</div>
					<div class="layui-card-body">
						<div class="layui-row">
							<div class="layui-row">
								<div class="layui-btn-group">
								    <button type="button" class="layui-btn layui-btn-primary">空闲</button>
								    <button type="button" class="layui-btn layui-btn-normal">使用中</button>
								    <button type="button" class="layui-btn layui-btn-danger">停用</button>
								  </div>
							</div>
							<div class="layui-row">
								<table class="svda-table">
									<tbody>
										<tr>
											<td>
												<div class="svda-table-col-content">
													<span class="svda-table-col-span">空闲</span>
												</div>
												<div class="svda-table-col-btn-gp">
													<div style="float: left;text-align: left;margin: 2px;">
														一排（右）1层01
													</div>
													<div class="layui-btn-group">
														
													</div>
												</div>
												
											</td>
											<td>
												<div class="svda-table-col-content">
													<span class="svda-table-col-span">空闲</span>
												</div>
												<div class="svda-table-col-btn-gp">
													<div style="float: left;text-align: left;margin: 2px;">
														一排（右）1层01
													</div>
													<div class="layui-btn-group">
														
													</div>
												</div>
											</td>
											<td>
												<div class="svda-table-col-content">
													<span class="svda-table-col-span">空闲</span>
												</div>
												<div class="svda-table-col-btn-gp">
													<div style="float: left;text-align: left;margin: 2px;">
														一排（右）1层01
													</div>
													<div class="layui-btn-group">
														
													</div>
												</div>
											</td>
										</tr>
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	var _zwgzpSrc = $("#zwgzp").attr("src");
	layui.use(["form","layer","upload"], function(){
		var layform = layui.form;
		$(function(){
			var wzxxOid = $("#wzxxOid").val();
			if(wzxxOid){
				$.ajax({
					url: basePath+"/wzxx/detailByOid?objectid="+wzxxOid,
					type: "post",
					dataType: "json",
					success: function(res){
						$("#wzmc").html(res.data.wzmc);
						$("#wzbh").html(res.data.wzbh);
						$("#wzms").val(res.data.wzms);
						$("#glwzbh").val(res.data.wzbh);
						var wzzpB64 = res.data.wzzp;
						if(wzzpB64){
							$("#wzzp").attr("src",wzzpB64);
						}
					}
				});
			}
		});
		var upload = layui.upload;
		upload.render({
			elem: '#upImg'
			,accept: "images"
			,acceptMime:"image/*"
			,url: ""
			,auto: false //选择文件后不自动上传
			,choose: function(obj){
				//将每次选择的文件追加到文件队列
				var files = obj.pushFile();
				//预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
				obj.preview(function(index, file, result){
					$("#zwgzp").attr("src",result);
				});
			}
		});
		layform.on("submit(saveBtn)",function(){
			var pData = layform.val('editFrom');
			var zwgzpData = $("#zwgzp").attr("src");
			if(_zwgzpSrc != zwgzpData){
				pData.zwgzp = zwgzpData;
			}
			$.ajax({
				url: basePath+"/zwg/doSave",
				type: "post",
				dataType: "json",
				data: pData,    
				success: function(res){
					showMsg.alert(res.msg,function(){
						if(res.code == "0"){
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
							parent.frames[0].loadStsxTable();
						}
					});
				}
			});
			return false;
		});
		$("#testBtn").click(function(){
			
		});
	});
	function initTable(conf){
		this.conf = conf;
		_this = this;
		this.init = function(){
			var url = _this.conf.url;
			if(url){
				$.ajax({
					url: url,
					type: "post",
					dataType: "json",
					data: pData,
					success: function(res){
						var code = res.code;
						if(code == "0"){
							_this.data = res.data;
							_this.loadTable();
						}
					}
				});
			}else{
				_this.loadTable();
			}
		};
		this.loadTable = function(){
			var loadData = _this.conf.data;
			var btns = _this.conf.buttons;
			var rn = _this.conf.rowNum;
			var cn = _this.conf.colNum;
			var elm = _this.conf.elm;
			if(rn && cn && elm){
				var tbodyC = _this.createTable();
				for(var ri=0;ri<rn;ri++){
					var trC = _this.createTr();
					for(var ci =0;ci<cn;ci++){
						var tdC = _this.createTd();
						var colC = _this.createColContent();
						tdC.append(colC);
						if(btns &&　btns.length > 0){
							var btnG = _this.createButtonGroup();
							for(var bi;bi<btns.length;i++){
								var btnConf = btns[bi];
								var btnC = _this.createButton(btnConf);
								btnG.append(btnC);
							}
							tdC.append(btnG);
						}
						trC.append(tdC);
					}
					tbodyC.append(trC);
				}
				$(elm).append(tbodyC);
			}
		};
		this.createTable = function(){
			var tbodyC = $("<table class='svda-table'><tbody></tbody></table>");
			return tbodyC;
		};
		this.createTr = function(){
			var trC = $("<tr></tr>");
			return trC;
		};
		this.createTd = function(){
			var tdC = $("<td></td>");
			return tdC;
		}
		this.createButtonGroup = function(){
			var btnGp = $('<div class="layui-btn-group svda-table-col-btn-gp"></div>');
			return btnGp;
		};
		this.createColContent = function(){
			var colContent = $('<div class="svda-table-col-content"></div>');
			return colContent;
		};
		this.createButton = function(btnConf){
			var btnC = $('<button type="button" class="layui-btn layui-btn-xs" groupName="'+btnConf.groupName+'">'+btnConf.text+'</button>');
			return btnC;
		}
	}
	</script>
</body>
</html>